import request from '@/utils/request'

export default {
    getUserList(searchModel) {
        return request({
            url: '/users',
            method: 'get',
            params: {
                page: searchModel.pageNo,
                paginate: searchModel.pageSize,
                pageSize: searchModel.pageSize,
                username: searchModel.username,
                state: searchModel.state,
                role: searchModel.role,
            }
        });
    },
    addUser(userFrom) {
        return request({
            url: '/users',
            method: 'post',
            data: userFrom
        });
    },
    deleteUser(id) {
        return request({
            url: '/users/delete/' + id,
            method: 'post',
            params: {
            }
        });
    },
    getUserById(id) {
        return request({
            url: '/users/' + id,
            method: 'get',
            params: {
            }
        });
    },
    updateUserInfo(user) {
        return request({
            url: '/users/' + user.id,
            method: 'post',
            data: user,
        });
    },
    saveUser(user) {

        if (user.id == null || user.id == undefined) {
            console.log(user.id);
            return this.addUser(user);
        }
        return this.updateUserInfo(user);
    },
    //获取全部员工列表
    getAllUserList() {
        return request({
            url: '/allUser',
            method: 'get',
        });
    },

    getManagerList() {
        return request({
            url: '/managers',
            method: 'get'
        })
    }
}